<!DOCTYPE html>
<html>
	<head>
		<title>-列表</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<!-- 所有的 css & js 资源 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
		<link rel="stylesheet" href="../../static/sa.css">
		<script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
		<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
		<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
		<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
		<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
		<script src="../../static/sa.js"></script>
	</head>
	<body>
		<div class="vue-box" style="display: none;" :style="'display: block;'">
			<div class="c-panel">
				<!-- ------------- 检索参数 ------------- -->
				<div class="c-title">检索参数</div>
				<el-form ref="form" :model='p' @submit.native.prevent>
					<sa-item type="text" name="客户名称" v-model="s.custName"></sa-item>
					<sa-item type="enum" name="订单状态" v-model="s.status" :jv="{1: '已结', 0: '未结'}" jtype="4" br></sa-item>
					<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
					<br />
					<sa-item name="综合排序">
						<el-radio-group  class="s-radio-text">
							<el-radio :label="0">默认</el-radio>
						</el-radio-group>
					</sa-item>
				</el-form>
				<!-- ------------- 快捷按钮 ------------- -->
				<sa-item type="fast-btn" show="add,export,reset"></sa-item>
				<!-- ------------- 数据列表 ------------- -->
				<el-table class="data-table" ref="data-table" :data="dataList" row-key="orderId" >
					<sa-td name="客户名称" prop="custName" ></sa-td>
					<sa-td name="订单创建日期" prop="createTime" type="datetime"></sa-td>
					<sa-td name="订单修改日期" prop="updateTime" type="datetime"></sa-td>
					<sa-td name="订单状态" prop="status" type="enum" :jv="{1: '已结清[green]', 0: '未结清[red]'}" jtype="1"></sa-td>
					<sa-td name="订单总额" prop="totalPrice" type="money"></sa-td>
					<sa-td name="已付金额" prop="amountPaid" type="money"></sa-td>
					<sa-td name="剩余应付" prop="unpaidAmount" type="money"></sa-td>
					<el-table-column label="操作" fixed="right">
						<template slot-scope="s">
							<el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">查看</el-button>
							<el-button class="c-btn" type="primary" icon="el-icon-edit" v-if="!s.row.status" @click="invoicing(s.row)">结账</el-button>
							<el-button class="c-btn" type="warning" icon="el-icon-edit" v-if="!s.row.status" @click="update(s.row)">修改</el-button>
							<el-button class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除</el-button>
						</template>
					</el-table-column>
				</el-table>
				<!-- ------------- 分页 ------------- -->
				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
			</div>
		</div>
		<script>
			var app = new Vue({
				components: {
					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),  
					"sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),		
				},
				el: '.vue-box',
				data: {
					p: { // 查询参数
						pageNo: 1,		// 当前页 
						pageSize: 10,	// 页大小
					},
					s:{
						custName:'',
						status:'',
					},
					dataCount: 0,
					dataList: [], // 数据集合 
				},
				methods: {
					// 刷新
					f5: function () {
						sa.ajax('/order/getAllOrder/' + this.p.pageNo + '/' + this.p.pageSize, this.s, function (res) {
							this.dataList = res.data.records; // 数据
							this.dataCount = res.data.total; // 数据总数
							sa.f5TableHeight();		// 刷新表格高度
						}.bind(this));
					},
					// 查看
					get: function (data) {
						sa.showIframe('订单详情', 'order-info.html?id=' + data.orderId, '1050px', '90%');
					},
                    invoicing:function (data){
                        sa.showIframe('订单结账', 'order-invoicing.html?id=' + data.orderId, '1050px', '90%');
                    },
					// 修改
					update: function (data) {
						sa.showIframe('修改订单', 'order-update.html?id=' + data.orderId, '1050px', '90%');
					},
					// 新增
					add: function () {
						sa.showIframe('新增订单', 'order-add.html?id=-1', '1000px', '90%');
					},
					// 删除
					del: function (data) {
						sa.confirm('是否删除，此操作不可撤销', function () {
							sa.ajax('/order/removeOrder/' + data.orderId, function (res) {
								this.f5()
								sa.ok('删除成功');

							}.bind(this))
						}.bind(this));
					},
				},
                    created: function () {
                        this.f5();
                        sa.onInputEnter();
                    }

			})
		</script>
	</body>
</html>
